<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "sys_category".
 *
 * @property string $id
 * @property string $name
 */
class SysCategory extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'sys_category';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['name'], 'string', 'max' => 10],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '主键',
            'name' => '分类名称',
        ];
    }

    public function getArticles()
    {
        return $this->hasMany(Article::className(),['sys_category_id'=>'id'])->inverseOf('sysCategory');
    }
}
